package yxy.cherry.paycenter.util;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Set;

import com.alibaba.fastjson.JSONObject;

public class SdkUtil {

	public static String getSignData(JSONObject info, String appsecret) {

		StringBuffer newsignstr = new StringBuffer();
		
		Set<String> parseset = info.keySet();
		ArrayList<String> list = new ArrayList<String>();
		list.addAll(parseset);
		Collections.sort(list);

		for(String key : list) {
			if(key.equals("sign")) {
				continue;
			}
			
			if(newsignstr != null && newsignstr.length() != 0) {
				newsignstr.append("&");
			}
			
			newsignstr.append(key).append("=").append(info.getString(key));
		}
		
		if(appsecret != null) {
			newsignstr.append(appsecret);
		}
		
		String newsign = HttpUtil.getMD5(newsignstr.toString());
		return newsign;
	}
}
